//
//  ByUIMineWelfareTwoVC.m
//  chequanbao_ios
//
//  Created by mc on 2017/6/13.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByUIMineWelfareTwoVC.h"

@interface ByUIMineWelfareTwoVC ()
{
    NSString *_title;
    NSString *_content1;
    NSString *_content2;
    NSString *_content3;
    NSString *_content4;
    NSString *_content5;
    NSString *_imageName;
}
@property (nonatomic, strong) UIScrollView *scroll;
@end

@implementation ByUIMineWelfareTwoVC

- (instancetype)initWithTitle:(NSString *)title
                    imageName:(NSString *)imageName
                      content1:(NSString *)content1
                     content2:(NSString *)content2
                     content3:(NSString *)content3
                     content4:(NSString *)content4
                     content5:(NSString *)content5{
    
    if ([super init]) {
        _title = title;
        _imageName = imageName;
        _content1 = content1;
        _content2 = content2;
        _content3 = content3;
        _content4 = content4;
        _content5 = content5;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImageView *bgImg = [self.view viewWithTag:888];
    [bgImg removeFromSuperview];
    
    self.title = _title;
    [self addLeftBackBarButtonItem];
    
    UIImage *image = [UIImage imageNamed:_imageName];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / image.size.width * image.size.height)];
    imageView.image = image;
    [self.view addSubview:imageView];
    
    
    self.scroll.frame = CGRectMake(0, imageView.bottom, self.view.width, SCREEN_HEIGHT - (SCREEN_WIDTH / image.size.width * image.size.height));
    
    UILabel *lable1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 20, 20)];
    lable1.text = _content1;
    lable1.font = B_FONT(16);
    lable1.textColor = [UIColor darkGrayColor];
    [self.scroll addSubview:lable1];
    
    
    NSAttributedString *str = [_content2 attributeString:14];
    CGRect rect = [_content2 getRectOfAttributeStringWithSize:CGSizeMake(self.scroll.width - 20, 10000) font:14];
//    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, lable1.bottom + 10, SCREEN_WIDTH - 20,  [_content2 getRectOfStringWithSize:CGSizeMake(SCREEN_WIDTH - 20, 10000) font:14].size.height)];
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, lable1.bottom + 10, SCREEN_WIDTH - 20, rect.size.height)];
//    label2.text = _content2;
    label2.attributedText = str;
    label2.numberOfLines = 0;
    label2.textColor = [UIColor colorWithR:132 g:132 b:132];
    label2.font = FONT(14);
    [self.scroll addSubview:label2];
    
    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(10, label2.bottom + 10, SCREEN_WIDTH - 20, 20)];
    label3.textColor = [UIColor darkGrayColor];
    label3.font = B_FONT(16);
    label3.text = _content3;
    [self.scroll addSubview:label3];
    
    str = [_content4 attributeString:14];
    rect = [_content4 getRectOfStringWithSize:CGSizeMake(self.scroll.width - 20, 10000) font:14];
//    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(10, label3.bottom + 10, SCREEN_WIDTH - 20, [_content4 getRectOfStringWithSize:CGSizeMake(SCREEN_WIDTH - 20, 10000) font:14].size.height)];
    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(10, label3.bottom + 10, SCREEN_WIDTH - 20, rect.size.height)];
    label4.textColor = [UIColor colorWithR:132 g:132 b:132];
    label4.numberOfLines = 0;
    label4.font = FONT(14);
    label4.text = _content4;
    [self.scroll addSubview:label4];
    
    str = [_content5 attributeString:14];
    rect = [_content5 getRectOfStringWithSize:CGSizeMake(self.scroll.width - 20, 10000) font:14];
    UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(10, label4.bottom + 10, SCREEN_WIDTH - 20, rect.size.height)];
    label5.textColor = [UIColor colorWithR:132 g:132 b:132];
    label5.font = FONT(14);
    label5.text = _content5;
    label5.numberOfLines = 0;
    [self.scroll addSubview:label5];
    
    self.scroll.contentSize = CGSizeMake(0, label5.bottom + 20);

//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.scroll.width - 20, [_content getRectOfStringWithSize:CGSizeMake(self.scroll.width - 20, 10000) font:15].size.height)];
//    label.numberOfLines = 0;
//    label.font = FONT(14);
//    label.text = _content;
//    label.textColor = [UIColor blackColor];
//    label.textAlignment = NSTextAlignmentLeft;
//    [self.scroll addSubview:label];
//    self.scroll.contentSize = CGSizeMake(0, label.bottom + 20);
 
}
- (UIScrollView *)scroll {
    
    if (!_scroll) {
        _scroll = [[UIScrollView alloc] init];
        _scroll.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1];
        [self.view addSubview:_scroll];
    }
    return _scroll;
}

@end
